<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');

if($_POST['submit']=='删除'){
	// if(empty($_POST["cbid"])) show_automsg('请先选择要删除的记录！',$GLOBALARR['curl'],1);
	// $u_id=implode(",",$_POST["cbid"]);

	// $db->sitedbexec("delete from ld_bank where id in($u_id)");

	// record_log('删除银行信息');
	// show_automsg('删除成功！',$GLOBALARR['curl']);
}

$pagecount=getnums($_GET["pagecount"],$GLOBALARR['pagecount']);
$option=getnums($_GET['option'],1);
$orderby=getnums($_GET['orderby'],1);
$quser=checkstr(trim($_GET['quser']));

$tmp_arr['toption'].='<a href="'.getqueurl('option',1).'" class="'.geteqval(array($option,1,'taselbtn','thabtn')).'">今日新增</a><a href="'.getqueurl('option',2).'" class="'.geteqval(array($option,2,'taselbtn','thabtn')).'">全部</a>';

$tmp_arr['torderby']='<a href="'.getqueurl('orderby',geteqval(array($orderby,1,'2','1'))).'" class="'.((strstr($orderby,'1')||strstr($orderby,'2'))?"tpaixusel":"tpaixu").'">'.geteqval(array($orderby,1,'时间↓','时间↑')).'</a>';

if(is_array($GLOBALARR['jjname'])){
foreach ($GLOBALARR['jjname'] as $k => $v) {
	$tmp_arr['tcolor'].='<a href="javascript:;" class="theacolor levelcolor'.$k.'">'.$v.'</a>';
}
}



$condition=' where is_default=1 ';

if($quser){
	
		$condition.=" and addressname like '%".$quser."%'";
	
}
if($option==1) $condition.=" and from_unixtime(add_time,'%Y-%m-%d')='".date('Y-m-d')."'";


$order='';
if($orderby==1 || !$isset($order)) $order=' order by id asc';
if($orderby==2) $order=' order by id asc';


$tmp_arr['tth']='<th><input type="checkbox" onclick="javascript:checkall(\'cbid[]\')"></th><th>序号</th><th>账号</th><th>姓名</th><th>联系人姓名</th><th>联系人电话</th><th>收货地址</th><th>备注</th><th style="width:160px">添加日期</th><th>挂单日期</th><th>金额</th>';

$psql="select count(0) from ld_address $condition";
$db->query($psql,3);
$pcount=$db->fval;
$pagecount=$pagecount;   //每页条数 
$astr="&lsaction=addresslist&pagecount=$pagecount&orderby=$orderby&option=$option&quser=$quser";	  //Url
$pagearr=pagelist($pagecount,$pcount,$astr);
$offset=$pagearr[1];

$sql="select * from ld_address  $condition $order limit $offset,$pagecount";
$db->query($sql);
$ii=0;
$amount=0;
foreach ($db->rs as $k => $v) {
	$ii++;
	$serialid=($pagearr[2]-1)*$pagecount+$ii;
	$rm=$member->getuserinfo($v['adid']);
	$rc=$member->getuv1($v['adid'],'user_level');
	$db->query("select amount,give_help_time from ld_give_help where uid=".$v['adid']."  order by id asc limit 1",2);
	$amount=$db->rs['amount'];
	$ftime=$db->rs['give_help_time'];
	$tmp_arr['ttr'].='<tr class="levelcolor'.$rc['user_level'].'">
						<td><input type="checkbox" name="cbid[]" value="'.$v['id'].'"></td>
						<td><span  title="'.$v["id"].'">'.$serialid.'</span></td>
						<td>'.$rm['uname'].'</td>
						<td>'.$rm['real_name'].'</td>
						<td align="left" >&nbsp;&nbsp;'.$v['addressname'].'</td>
						<td align="left" >&nbsp;&nbsp;'.$v['phone'].'</td>
						<td align="left" >&nbsp;&nbsp;'.$v['address'].'</td>
						<td align="left" style="width:160px" title="'.$v['beizhu'].'">&nbsp;<div style="float:left;width:150px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;cursor:pointer">&nbsp;&nbsp;'.$v['beizhu'].'</div></td>
						<td align="left" title="'.formatdate($v['add_time']).'">&nbsp;&nbsp;'.formatdate($v['add_time'],1).'</td>
						<td align="center">'.date("Y-m-d H:i:s",$ftime).'</a></td>
						<td align="center">'.$amount.'</a></td>
						</tr>';


}


$tmp_arr['tcount']=$pcount;
$tmp_arr['ttitle']=getmenu($GLOBALARR['menu'],'addresslist');
$tmp_arr['tpage']=$pagearr[0];
admin_two($tmp_arr);

?>